//
//  SsehViewController.m
//  SsehMaster
//
//  Created by 杨阳 on 2018/8/3.
//  Copyright © 2018年 yinlong. All rights reserved.
//

#import "SsehViewController.h"
#import "TabBarItem.h"

@interface SsehViewController ()

@property (nonatomic,strong) NSArray * itemArray;

@end

@implementation SsehViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self baseSetting];
}

-(NSArray *)itemArray{
    if (_itemArray == nil) {
        _itemArray = [[NSArray alloc]init];
    }
    return _itemArray;
}

-(void)baseSetting{
    self.itemArray = [NSArray arrayWithObjects:[TabBarItem withForSet:@"SsehHomePageViewController" icon:@"homePage_unSelect" selectIcon:@"homePage_select" iconName:@"首页"],[TabBarItem withForSet:@"SsehOrderViewController" icon:@"order_unSelect" selectIcon:@"order_select" iconName:@"订单"],[TabBarItem withForSet:@"SsehMineViewController" icon:@"mine_unSelect" selectIcon:@"mine_select" iconName:@"我的"],nil];
    self.tabBar.barTintColor = [UIColor whiteColor];
    self.view.backgroundColor = [UIColor whiteColor];
    [self createItem];
}
- (void)createItem {
    for (int i = 0; i < _itemArray.count;i++) {
        TabBarItem *item = self.itemArray[i];
        UITabBarItem *tabBarItem = [[UITabBarItem alloc]initWithTitle:item.iconName image:[[UIImage imageNamed:item.icon]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage: [[UIImage imageNamed:item.selectIcon]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
        NSDictionary *selectDic = @{NSForegroundColorAttributeName:[UIColor appColor]};
        NSDictionary *nomalDic = @{NSForegroundColorAttributeName:RGBColor(118, 118, 118)};
        [tabBarItem setTitleTextAttributes:nomalDic forState:UIControlStateNormal];
        [tabBarItem setTitleTextAttributes:selectDic forState:UIControlStateSelected];
        
        Class class = NSClassFromString(item.className);
        UIViewController *controller = [[class alloc]init];
        controller.tabBarItem = tabBarItem;
        UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:controller];
        
        NSDictionary * dict = [NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName];
        nav.navigationBar.titleTextAttributes = dict;
        nav.navigationBar.barTintColor = [UIColor appColor];
        [self addChildViewController:nav];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
